feat: Add Node.js bindings via napi-rs#253
feat: Add Node.js bindings via napi-rs#253davidfestal wants to merge 9 commits intooras-project:mainfrom
Conversation
Introduces Node.js bindings for the rust-oci-client using napi-rs, enabling Node.js applications to interact with OCI registries. Features: - 17 OciClient methods: pull, push, manifests, blobs, tags, referrers - Authentication helpers: anonymous, basic, bearer - Platform resolver configuration via os/arch/variant filter - Full TypeScript definitions auto-generated Supported platforms (7 targets): - macOS x86_64 and ARM64 - Linux x86_64 and ARM64 (glibc) - Linux x86_64 and ARM64 (musl/Alpine) - Windows x86_64 CI/CD: - Build and test workflows for all platforms - Publish workflow for npm releases - Node.js 22 and 24 support - Integration tests with Zot registry Assisted-by: Cursor Signed-off-by: David Festal <dfestal@redhat.com>
|
cc @TerryHowe This is the work I briefly told you about last week at KubeCon EU when discussing at the ORAS booth. |
|
Before opening this PR, the result of the bindings publish workflow has already been pushed from my fork to my personal scope on NPMJS: @dfatwork/oci-client. |
|
cc @sabre1041 |
Ah, okay. Thanks. I'm not a maintainer on this project though, so they will need to chime in. |
There was a problem hiding this comment.
Pull request overview
Adds a new napi-rs-based Node.js/TypeScript binding package for oci-client, plus CI workflows to build/test/publish prebuilt binaries across major platforms.
Changes:
- Introduces a new
bindings/nodejsworkspace crate exposing anOciClientN-API surface (auth/config/manifest/blob APIs + TS types). - Adds Node-side tooling (Yarn v4, version sync script, TS config, tests including mock registry + Zot integration).
- Adds GitHub Actions workflows for multi-target Node build/test, npm publish, and wires release flow to run Node checks.
Reviewed changes
Copilot reviewed 22 out of 23 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| Cargo.toml | Converts repo to a Cargo workspace and centralizes shared package/dependency metadata. |
| bindings/nodejs/yarn.lock | Adds Yarn lockfile for Node binding toolchain dependencies. |
| bindings/nodejs/tsconfig.json | TypeScript compiler settings for the Node bindings package. |
| bindings/nodejs/src/lib.rs | Implements the N-API Rust bindings (client/config/auth/types/manifests/constants). |
| bindings/nodejs/scripts/sync-version.js | Syncs Node package version to Rust workspace version. |
| bindings/nodejs/scripts/fix-const-enums.js | Post-processes generated .d.ts to avoid const enum declarations. |
| bindings/nodejs/README.md | Documents installation/usage and exposed APIs for Node consumers. |
| bindings/nodejs/package.json | Defines the npm package, scripts, napi targets, and dev dependencies. |
| bindings/nodejs/Cargo.toml | New Rust crate manifest for the Node bindings (cdylib) and feature wiring. |
| bindings/nodejs/build.rs | Sets up napi-build for generating bindings at build time. |
| bindings/nodejs/.yarnrc.yml | Configures Yarn to use node-modules linker. |
| bindings/nodejs/.gitignore | Ignores generated bindings artifacts, build outputs, and node_modules. |
| bindings/nodejs/.gitattributes | Sets text/binary attributes and marks generated binding outputs as non-detectable. |
| bindings/nodejs/.editorconfig | Establishes formatting defaults for the Node bindings subtree. |
| bindings/nodejs/test/zot-registry.ts | Test utility to run Zot registry container for integration/push tests. |
| bindings/nodejs/test/tsconfig.json | TS config for running AVA tests as ES modules. |
| bindings/nodejs/test/package.json | Marks tests directory as ESM (type: module). |
| bindings/nodejs/test/mock-registry.ts | Mock HTTP registry server using existing Rust fixtures for deterministic tests. |
| bindings/nodejs/test/bindings.spec.ts | AVA test suite covering bindings behavior (auth/config/pull/push/etc.). |
| .github/workflows/release.yml | Gates crates.io publish on Node build/test and adds npm publish job call. |
| .github/workflows/nodejs-publish-call.yml | Reusable workflow to assemble artifacts and publish to npm. |
| .github/workflows/nodejs-build.yml | Entry workflow to run Node build/test on PRs and main branch changes. |
| .github/workflows/nodejs-build-call.yml | Reusable multi-platform build/test matrix for Node binaries + TS bindings. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
TerryHowe
left a comment
There was a problem hiding this comment.
Great work overall — the binding coverage, test setup, and multi-platform CI are well done. Inline comments cover the critical and important issues. The two blockers are the release.yml coupling (Rust publish shouldn't depend on Node.js build success) and the platform filter bug (Os::Other/Arch::Other won't match typed oci-spec variants for standard platforms like linux/amd64).
... according to review comments Signed-off-by: David Festal <dfestal@redhat.com> Assisted-by: Cursor
Signed-off-by: David Festal <dfestal@redhat.com> Assisted-by: Cursor
Signed-off-by: David Festal <dfestal@redhat.com>
9e5610b to
ec83b6d
Compare
to avoid building napi bindings on bare cargo commands. Signed-off-by: David Festal <dfestal@redhat.com>
Signed-off-by: David Festal <dfestal@redhat.com>
…te on dependency changes Signed-off-by: David Festal <dfestal@redhat.com>
Signed-off-by: David Festal <dfestal@redhat.com>
Signed-off-by: David Festal <dfestal@redhat.com>
|
@TerryHowe I fixed all your comments. |
|
@thomastaylor312 @bacongobbler @flavio any feedback on this PR ? |
Introduces Node.js bindings for the
rust-oci-clientusingnapi-rs, enabling Node.js applications to interact with OCI registries.Features:
Supported platforms (7 targets):
CI/CD:
Note:
In order to allow the publishing of the Javascript bindings to NPMJS, a
NPM_TOKENsecret will be required in this repository.Assisted-by: Cursor